
public class Card implements Comparable<Card>{

	public static enum Suit {SPADE, HEART, CLUB, DIAMOND}

	public Suit suit;
	public int value;

	public Card(Suit s, int val)
	{
		suit = s;
		value = val;
	}

	@Override
	public String toString()
	{
		String output = valueString() + " of ";
		switch (suit)
		{
		case SPADE:
			output += "spades";
			break;
		case CLUB:
			output += "clubs";
			break;
		case DIAMOND:
			output += "diamonds";
			break;
		case HEART:
			output += "hearts";
			break;
		}
		return output;
	}

	public String toStringShort()
	{
		String output = "" + valueChar();
		switch (suit)
		{
			case SPADE:   output += "S"; break;
			case CLUB:    output += "C"; break;
			case DIAMOND: output += "D"; break;
			case HEART:   output += "H"; break;
		}
		return output;
	}

	public int compareTo(Card c)
	{
		if (c.value > value)
			return -1;
		if (c.value < value)
			return 1;
		return 0;
	}

	public Card dominant(Card c)
	{
		if (c == null)
			return this;
		if (c.compareTo(this) > 0)
			return c;
		else
			return this;
	}

	public boolean equals(Card c)
	{
		return (c.value == value && c.suit.equals(suit));
	}

	public String valueString()
	{
		switch(value)
		{
			case 11: return "Jack";
			case 12: return "Queen";
			case 13: return "King";
			case 14: return "Ace";
			default: return "" + value;
		}
	}

	public char valueChar()
	{
		switch(value)
		{
			case 10: return 'T';
			case 11: return 'J';
			case 12: return 'Q';
			case 13: return 'K';
			case 14: return 'A';
			default: return (char) (value + '0');
		}
	}

	public Card clone()
	{
		Card c= new Card(suit, value);
		return c;
	}
}
